
clear all
set more off

use "data/raw/anticipated-persuasion-deidentified", clear 

* Classify private support
gen join = defunding_opposition=="Yes"
lab var join "Joined campaign"
keep if join

* Drop pre-randomization attritters and flag post-randomization attriters
* condition: excuse or noexcuse
drop if !inlist(condition, "excuse", "noexcuse")

gen attrit = 0
replace attrit = 1 if defunding_opposition == "" | (defunding_opposition == "Yes" & percentage_4 == "")
lab var attrit "Respondent attritted post-randomization"

drop attention
gen attention = screener=="Extremely interested,Not at all interested"
keep if attention
drop attention screener

* Generate outcome and treatment variables
destring percentage_4, replace
rename percentage_4 percentage
label var percentage "Percentage believe will be persuaded"

gen excuse = condition=="excuse"
lab var excuse "Excuse condition"
gen noexcuse = condition=="noexcuse"
lab var noexcuse "No excuse condition"
drop condition

* Generate demographic and control variables
gen ind = party=="Independent"
lab var ind "Independent"
drop party

gen partisan = .
replace partisan = 2 if liberal == "Very conservative"
replace partisan = 1 if liberal == "Conservative"
replace partisan = 0 if liberal == "Neither liberal nor conservative"
replace partisan = -1 if liberal == "Liberal"
replace partisan = -2 if liberal == "Very liberal"
label var partisan "Partisan leaning"


destring year, replace
gen age = 2021-year
lab var age "Age"
drop year

gen age2 = age^2
lab var age2 "Age squared"
gen hisp = hispanic=="Yes"
lab var hisp "Spanish, Hispanic, or Latino"
drop hispanic
gen male = sex == "Male"
lab var male "Male"
drop sex

lab var education "Education level"

gen white = race=="Caucasian/White"
lab var white "White"
lab var race "Race"



keep attrit percentage excuse noexcuse education race ind partisan age age2 hisp male white 

save "data/working/anticipated-persuasion.dta", replace
exit,clear
